package com.qijian.maindata.domain;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qijian.common.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.util.Date;

/***
 * 泛微材料清单发放
 */

@Data
@ToString
@TableName("main_material")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BillsOfMaterial {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long id;

    @ApiModelProperty(value = "标题")
    private String title;

    @ApiModelProperty(value = "流程编号")
    private String number;

    @ApiModelProperty(value = "项目名称")
    private String projectName;

    @ApiModelProperty(value = "项目号")
    private String projectNo;

    @ApiModelProperty(value = "业务日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date businessDate;


    @ApiModelProperty(value = "归档日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date archiveDate;

    @ApiModelProperty(value = "创建人")
    private String creator;

    @ApiModelProperty(value = "创建部门")
    private String creatorDept;


    public static BillsOfMaterial buildMaterial(JSONObject jsonObject){
        return BillsOfMaterial.builder()
                .id(jsonObject.getLong("requestid"))
                .title(jsonObject.getStr("requestname"))
                .number(jsonObject.getStr("field8235span"))
                .projectName(jsonObject.getStr("field8237"))
                .projectNo(jsonObject.getStr("field8236span"))
                .businessDate(jsonObject.getDate("field8234span"))
                .archiveDate(jsonObject.getDate("filingdatespan"))
                .creator(jsonObject.getStr("field8238span"))
                .creatorDept(jsonObject.getStr("field8240span")).build();



    }

}
